package com.lzk.auth.controller;


import com.lzk.auth.service.SysUserService;
import com.lzk.common.result.Result;
import com.lzk.model.system.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

@Api(tags="余额管理接口")
@RestController
@RequestMapping("/admin/personal/money")



public class moneyController {
    @Autowired
    private SysUserService  sysUserService;

    @ApiOperation(value = "更新用户")
    @PutMapping("recharge")
    public Result updateById(@RequestBody SysUser user) {

        sysUserService.updateById(user);

        return Result.ok();
    }

    @ApiOperation(value = "获取当前用户信息")
    @GetMapping
    public Result getCurrentUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String currentPrincipalName = authentication.getName();
        SysUser user = sysUserService.getUserByUsername(currentPrincipalName);


        return Result.ok(user);
    }


}
